# -*- coding: utf-8 -*-
'''
Created on Oct 12, 2013

@author: LONG HOANG GIANG
'''

import lib
import os
import json



def joindatafile(path1, path2):
    
    if not path1.endswith("/"): path1 += "/"
    if not path2.endswith("/"): path2 += "/"
    print path1, path2

    if not os.path.isfile(path1 + "data-1") or not os.path.isfile(path2 + "data"):
        raise Exception, "File Not Found"
    
    
    data1 = json.loads(lib.decryptCipher(lib.gz_file_get_content(path1+"data")))
    data2 = json.loads(lib.decryptCipher(lib.gz_file_get_content(path2+"data")))
    lib.gz_file_put_content(lib.encryptCipher(json.dumps(data1)), path1+"data-1")
    for item in data2:
        data1.append(item)
    lib.gz_file_put_content(lib.encryptCipher(json.dumps(data1)), path1+"data")
    
    
    
    
if __name__ == '__main__':
    
    
    joindatafile(r"f:/longhoanggiang/truyentext/__tunghoanh/do-thi", r"f:/longhoanggiang/truyentext/__tunghoanh/ngon-tinh")